package com.moji.controller.web;


import com.moji.common.base.ApiResult;
import com.moji.entity.MjProduct;
import com.moji.entity.MjSolution;
import com.moji.entity.dto.RouterrDto;
import com.moji.entity.vo.CommonProductDetailDTO;
import com.moji.service.MjSolutionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 解决方案表(MjSolution)表控制层
 *
 * @author makejava
 * @since 2024-07-21 14:36:48
 */
@RestController
@RequestMapping("web/mjSolution")
@Api(tags = "解决方案列表相关web接口", value = "解决方案列表相关web接口")
public class MjSolutionController {
    /**
     * 服务对象
     */
    @Resource
    private MjSolutionService mjSolutionService;

    /**
     * 分页查询
     *
     * @return 查询结果
     */
    @GetMapping
    @ApiOperation(value = "获取全部解决方案,不需要传参数")
    public ApiResult<List<MjSolution>> queryByPage() {
        return ApiResult.ok(this.mjSolutionService.queryByPage());
    }

    /**
     * 通过主键查询单条数据
     *
     * @param
     * @return 单条数据
     */
    @PostMapping("/detail")
    @ApiOperation(value = "根据id查看解决方案", response = MjSolution.class)
    public ApiResult<MjSolution> queryById(@RequestBody RouterrDto routerrDto) {

        if (this.mjSolutionService.queryById(routerrDto) == null) {
            return ApiResult.routerFailed("查无此router");
        }
        return ApiResult.ok(this.mjSolutionService.queryById(routerrDto));
    }

}

